package com.lst.model;

import java.math.BigDecimal;

import com.google.gson.annotations.Expose;

/**
 * 
 * @ClassName: OrdinaryModel
 * @Description: 用于排序的model
 * @author an wh
 * @date 2016年12月21日 上午9:28:55
 * 
 */
public class OrdinaryModel implements Comparable<OrdinaryModel> {
    @Expose
    private Integer id;
    @Expose
    private String name;
    @Expose
    private BigDecimal value;
    @Expose
    private String note;

    private BigDecimal diff;
    
    @Expose
    private String css;
    

    /**
     * @return the diff
     */
    public BigDecimal getDiff() {
	return diff;
    }

    /**
     * @param diff
     *            the diff to set
     */
    public void setDiff(BigDecimal diff) {
	this.diff = diff;
    }

    public OrdinaryModel() {
	super();
    }

    public OrdinaryModel(Integer id, String name, BigDecimal value, String note,String css) {
	super();
	this.id = id;
	this.name = name;
	this.value = value;
	this.note = note;
	this.css = css;
    }

    public OrdinaryModel(Integer id, String name, BigDecimal value,
	    String note, BigDecimal diff,String css) {
	super();
	this.id = id;
	this.name = name;
	this.value = value;
	this.note = note;
	this.diff = diff;
	this.css = css;
    }

    public Integer getId() {
	return id;
    }

    public void setId(Integer id) {
	this.id = id;
    }

    public String getNote() {
	return note;
    }

    public void setNote(String note) {
	this.note = note;
    }

    public String getName() {
	return name;
    }

    public void setName(String name) {
	this.name = name;
    }

    public BigDecimal getValue() {
	return value;
    }

    public void setValue(BigDecimal value) {
	this.value = value;
    }

    @Override
    public int compareTo(OrdinaryModel o) {
	BigDecimal thisVal = this.value;
	BigDecimal v = o.getValue();

	Integer re = 0;

	if (this.value.compareTo(v) != 0) {
	    re = this.value.compareTo(v);
	} else {
	    // 两个身体机能与3对比
	    if (this.diff != null) {
		BigDecimal thisDiff = this.diff.subtract(new BigDecimal(3))
			.abs();
		BigDecimal diff = o.getDiff().subtract(new BigDecimal(3)).abs();

		re = diff.compareTo(thisDiff);
	    } else {
		re = this.value.compareTo(v);
	    }

	}

	return re;
    }
}
